package com.ramnight.unify.boot.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

@Component
public class SpringHolder implements ApplicationContextAware, ApplicationEventPublisherAware {
	private static ApplicationContext applicationContext;

	private static ApplicationEventPublisher eventPublisher;

	public static ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	public static ApplicationEventPublisher getEventPublisher() {
		return eventPublisher;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		SpringHolder.applicationContext = applicationContext;
	}

	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		SpringHolder.eventPublisher = applicationEventPublisher;
	}
}
